package com.ithong.mp;

import com.baomidou.mybatisplus.core.parser.ISqlParser;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.ithong.mp.injectors.MySqlInjector;
import com.ithong.mp.plugins.MyInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.aop.interceptor.PerformanceMonitorInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@MapperScan("com.ithong.mp.mapper")
@Configuration
public class MyBatisPlusConfig {

//    配置分页插件
    @Bean
    public PaginationInnerInterceptor paginationInnerInterceptor(){
        return new PaginationInnerInterceptor();
    }

//    @Bean//注入自定义的拦截器(插件)
//    public MyInterceptor myInterceptor(){
//        return new MyInterceptor();
//    }

//    @Bean //SQL分析插件
//    public SqlExplainInterceptor sqlExplainInterceptor(){
//        SqlExplainInterceptor sqlExplainInterceptor = new SqlExplainInterceptor();
//        List<ISqlParser> list = new ArrayList<>();
//        list.add(new );//全表更新.删除的阻断器
//        sqlExplainInterceptor.setSqlParseList();
//        return new SqlExplainInterceptor();
//    }

    //乐观锁插件
//    @Bean
//    public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor(){
//        return
//    }

    /**
     * 注入自定义的sql注入器
     * @return
     */
    @Bean
    public MySqlInjector mySqlInjector(){
        return new MySqlInjector();
    }


}
